package com.woniuxy.mesboot.controller;

import com.woniuxy.mesboot.dto.TicketsDetailsDTO;
import com.woniuxy.mesboot.entity.MesOrdersdetail;
import com.woniuxy.mesboot.entity.MesTicketdetail;
import com.woniuxy.mesboot.service.TicketsDetailService;
import com.woniuxy.mesboot.util.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 *
 * @author : 黑川
 * @version : 1.0
 * @Project : mes-boot
 * @Package : com.woniuxy.mesboot.controller
 * @ClassName : .java
 * @createTime : 2023/5/23 19:46
 * @Description : 工单明细表
 */
@RestController
@RequestMapping("ticketdetails")
public class TicketsDetailController {
    @Resource
    private TicketsDetailService detailService;
    @PostMapping("queryAll")
    public Result queryAll(){
        List<MesTicketdetail> list = detailService.selectAll();
        return Result.ok().data("list",list);
    }
    @PostMapping
    public Result add(@RequestBody TicketsDetailsDTO detailsDTO){
        int i = detailService.insertSelective(detailsDTO);
        if(i>0){
            return Result.ok("添加成功");
        }else {
            return Result.error("添加失败");
        }
    }
    @GetMapping("{id}")
    public Result queryById(@PathVariable Long id){
        MesTicketdetail ticketdetail = detailService.selectByPrimaryKey(id);
        return Result.ok().data("ticketdetail",ticketdetail);
    }
    @PutMapping
    public Result update(@RequestBody MesTicketdetail ticketdetail){
        int i = detailService.updateByPrimaryKeySelective(ticketdetail);
        if(i>0){
            return Result.ok("修改成功");
        }else {
            return Result.error("修改失败");
        }
    }
//    @DeleteMapping("{id}")
//    public Result delete(@PathVariable Long id){
//        int i = detailService.deleteByPrimaryKey(id);
//        if(i>0){
//            return Result.ok("删除成功");
//        }else {
//            return Result.error("删除失败");
//        }
//    }
}
